{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "2f887c2f",
   "metadata": {},
   "source": [
    "朴素贝叶斯（Naive Bayesian algorithm）是有监督学习的一种分类算法，它基于“贝叶斯定理”实现，贝叶斯定理是基于概率论和统计学的相关知识实现的，因此在正式学习“朴素贝叶斯算法”前，我们有必要先认识“贝叶斯定理”。"
   ]
  },
  {
   "attachments": {
    "image.png": {
     "image/png": "iVBORw0KGgoAAAANSUhEUgAAAOoAAAA+CAIAAACqWRAgAAAWjUlEQVR4Ae1dX2Rjzxefh1hXxYqKqyoqVkTFqhCiIioqqqKioqKiovJwH6KiVlRUhYoVUbWi8pCHWlUVq1asqKqoiooKoWpVVKyKFRVxVV11VR7m55fR+c5v7k2a7Xbb7vd3z0N77tyZM2dOPnfumTN/LoAKKRb4ay0A/lrNFcUVC0AFvgoI/mILKPD9i388RXUFvgoG/mILKPD9i388RXUFvi+MgVwud3R09GglDg4Ozs7Oei8uiiKZOZVK1et1MuVJ+Hw+n06nexF1c3NDKiCK4vr6ei8FUR4Fvr3bqqecgiBUq9VisVgul2u1WqPR4Hm+U8mdnR2Hw1EsFqkMgiBcXl6W23R+fo7kNBoNCnwQQovFsra2RhXvdLm0tJTNZsm7Hz58sFgsXTQUBOHq6ur6+rpWqyF9fvz40WgTKYfkC4XC+Ph4JpMhE2X5er3u9/tzuRy+K4rizMyMz+fDKd0ZBb7d7dPrXVEUg8Gg1Wp1u93v37/X6XQWi8XpdLpcLmebMpmMIAikuHK5rNPpvn79SiZCCE9PT30+n8PhGB4eHhgYsNlsSI7L5bLb7T6fr1gstlotVMpgMCSTSUqC7OX29rZKpYpGo+Tdu7s7p9Pp8XikDwbKtrm5aW+T2WzWarWoUVNTU2NjY1arNZlMUgUvLy91Ol2PKn348AEA8OXLF1Ilnuffv38fi8XIxE68At9Olvm19FardXR0lMvlrFYrAMDv9xfuKZ/PBwIBtVrt8/lubm6wXLfbPT8/jy8x02w2j4+PE4kEAMBgMOzt7d1LKnz58sVkMul0ulQ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BgMpmWlpaW2xQKhTweT39//+TkpHTdD4Qwk8n09fXJLp94ETsp8H0Rsz+m0mw26/P5AoFANBpFJ2/Mzs5K3/uU6I2Njb6+PrKrrtVqgUDA4XBMTEx4vd6JiQnLPTmdzlgsdnBwINtbQwhnZ2fNZjNVxQteKvB9QeM/R9W1Wo1hGNmF6qIokltoqRiZVDme51mWlS4aluZ8thQFvs9m6heriOO46enp368+l8t1+ijn7wt/nAQFvo+z299U6uzsbGhoSHogxi+1odFoGI1G6sPcvyThT2RW4PsnrPrqZO7s7Oj1+l6+3tBJ9fn5+ZGREerEgk6Zny1dge+zmfqFK9rc3BwZGXmcErlcbnp6WjYW8TiBT1VKge9TWfIvkCON4/aodJdz7nqU8Iey/QfKyqAHb1PXTQAAAABJRU5ErkJggg=="
    }
   },
   "cell_type": "markdown",
   "id": "cb92b0e8",
   "metadata": {},
   "source": [
    "## 贝叶斯定理\n",
    "贝叶斯定理的发明者 托马斯·贝叶斯 提出了一个很有意思的假设：“如果一个袋子中共有 10 个球，分别是黑球和白球，但是我们不知道它们之间的比例是怎么样的，现在，仅通过摸出的球的颜色，是否能判断出袋子里面黑白球的比例？”\n",
    "\n",
    "上述问题可能与我们高中时期所接受的的概率有所冲突，因为你所接触的概率问题可能是这样的：“一个袋子里面有 10 个球，其中 4 个黑球，6 个白球，如果你随机抓取一个球，那么是黑球的概率是多少？”毫无疑问，答案是 0.4。这个问题非常简单，因为我们事先知道了袋子里面黑球和白球的比例，所以很容易算出摸一个球的概率，但是在某些复杂情况下，我们无法得知“比例”，此时就引出了贝叶斯提出的问题。\n",
    "\n",
    "在统计学中有两个较大的分支：一个是“频率”，另一个便是“贝叶斯”，它们都有各自庞大的知识体系，而“贝叶斯”主要利用了“相关性”一词。下面以通俗易懂的方式描述一下“贝叶斯定理”：通常，事件 A 在事件 B 发生的条件下与事件 B 在事件 A 发生的条件下，它们两者的概率并不相同，但是它们两者之间存在一定的相关性，并具有以下公式（称之为“贝叶斯公式”）：\n",
    "![image.png](attachment:image.png)\n",
    "符号意义\n",
    "首先我们要了解上述公式中符号的意义：\n",
    "- P(A) 这是概率中最基本的符号，表示 A 出现的概率。比如在投掷骰子时，P(2) 指的是骰子出现数字“2”的概率，这个概率是 六分之一。\n",
    "- P(B|A) 是条件概率的符号，表示事件 A 发生的条件下，事件 B 发生的概率，条件概率是“贝叶斯公式”的关键所在，它也被称为“似然度”。\n",
    "- P(A|B) 是条件概率的符号，表示事件 B 发生的条件下，事件 A 发生的概率，这个计算结果也被称为“后验概率”。\n",
    "有上述描述可知，贝叶斯公式可以预测事件发生的概率，两个本来相互独立的事件，发生了某种“相关性”，此时就可以通过“贝叶斯公式”实现预测。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "02d50660",
   "metadata": {},
   "source": [
    "## 条件概率\n",
    "条件概率是“贝叶斯公式”的关键所在。\n",
    "我们可以从“相关性”这一词语出发。举一个简单的例子，比如小明和小红是同班同学，他们各自准时回家的概率是 P(小明回家) = 1/2 和 P(小红回家) =1/2，但是假如小明和小红是好朋友，每天都会一起回家，那么 P(小红回家|小明回家) = 1 (理想状态下)。\n",
    "\n",
    "上述示例就是条件概率的应用，小红和小明之间产生了某种关联性，本来俩个相互独立的事件，变得不再独立。但是还有一种情况，比如小亮每天准时到家 P(小亮回家) =1/2，但是小亮喜欢独来独往，如果问 P(小亮回家|小红回家) 的概率是多少呢？你会发现这两者之间不存在“相关性”，小红是否到家，不会影响小亮的概率结果，因此小亮准时到家的概率仍然是 1/2。\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "53304c05",
   "metadata": {},
   "source": [
    "## 先验概率\n",
    "在贝叶斯看来，世界并非静止不动的，而是动态和相对的，他希望利用已知经验来进行判断，那么如何用经验进行判断呢？这里就必须要提到“先验”和“后验”这两个词语。我们先讲解“先验”，其实“先验”就相当于“未卜先知”，在事情即将发生之前，做一个概率预判。比如从远处驶来了一辆车，是轿车的概率是 45%，是货车的概率是 35%，是大客车的概率是 20%，在你没有看清之前基本靠猜，此时，我们把这个概率就叫做“先验概率”。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "be2ac4b2",
   "metadata": {},
   "source": [
    "## 后验概率\n",
    "我们知道每一个事物都有自己的特征，比如前面所说的轿车、货车、客车，它们都有着各自不同的特征，距离过远的时候，我们无法用肉眼分辨，而当距离达到一定范围内就可以根据各自的特征再次做出概率预判，这就是后验概率。比如轿车的速度相比于另外两者更快可以记做 P(轿车|速度快) = 55%，而客车体型可能更大，可以记做 P(客车|体型大) = 35%。\n",
    "\n",
    "如果用条件概率来表述 P(体型大|客车)=35%，这种通过“车辆类别”推算出“类别特征”发生的的概率的方法叫作“似然度”。这里的似然就是“可能性”的意思。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ebc6afa9",
   "metadata": {},
   "source": [
    "## 朴素+贝叶斯\n",
    "实际上贝叶斯定理就是求解后验概率的过程，而核心方法是通过似然度预测后验概率，通过不断提高似然度，自然也就达到了提高后验概率的目的。\n",
    "\n",
    "我们知道“朴素贝叶斯算法”由两个词语组成。朴素（native）是用来修饰“贝叶斯”这个名词的。按照中文的理解“朴素”意味着简单不奢华。朴素的英文是“native”，意味着“单纯天真”。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c4d96b9e",
   "metadata": {},
   "source": [
    "## 多特征分类问题"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "489e3a7b",
   "metadata": {},
   "source": [
    "比如现在有 A1 和 A2 两个类，其中  A1 具有 b、c 两个特征，A2 具有 b、d 两个 特征，如果是你会怎么区分这两个类呢？很简单看看是存在 c ，存在的就是 A1，反之则是 A2。但是现实的情况要复杂的多，比如 100 个 A1样本中有 80% 的样本具有特征 c，而且剩余的 20% 具有了特征 d，那么要怎么对它们分类呢？其实只要多加判断还是可以分清，不过要是纯手工分类，那就恐怕得不偿失了。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f00a1fa7",
   "metadata": {},
   "source": [
    "统计学是通过搜索、整理、分析、描述数据等手段，以达到推断、预测对象的本质，统计学用到了大量的数学及其它学科的专业知识，其应用范围几乎覆盖了社会科学和自然科学的各个领域。\n",
    "\n",
    "下面我们使统计学的相关知识解决上述分类问题，分类问题的样本数据大致如下所示：\n",
    "```shell\n",
    "[特征 X1 的值,特征 X2 的值,特征 X3 的值,......,类别 A1]\n",
    "[特征 X1 的值,特征 X2 的值,特征 X3 的值,......,类别 A2]\n",
    "```\n",
    "\n",
    "解决思路: 这里我们先简单的采用 1 和 0 代表特征值的有无，比如当 X1 的特征值等于 1 时，则该样本属于 A1 的类别概率；特征值 X2 值为 1 时，该样本属于类别 A1 的类别的概率。依次类推，然后最终算出该样本对于各个类别的概率值，哪个概率值最大就可能是哪个类。\n",
    "\n",
    "上述思路就是贝叶斯定理的典型应用，如果使用条件概率表达，如下所示：\n",
    "\n",
    "```shell\n",
    "P(类别A1|特征X1，特征X2，特征X3，…)\n",
    "```\n",
    "\n",
    "上述式子表达的意思是：在特征 X1、X2、X3 等共同发生的条件下，类别 A1 发生的概率，也就是后验概率，依据贝叶斯公式，我们可以使用似然度求解后验概率，某个特征的似然度如下：\n",
    "\n",
    "```shell\n",
    "P(特征X1|类别A1，特征X2，特征X3，…)\n",
    "```"
   ]
  },
  {
   "attachments": {
    "image-2.png": {
     "image/png": "iVBORw0KGgoAAAANSUhEUgAAAaQAAAAXCAIAAADLB6wNAAAR4klEQVR4Ae1c72cryxu//9OwalUdUeuIKKmoa1VIXuRFREXVOipCREVERBx5sS+ioiLiiKg6oiqqjhUhRERdccW1jjiiVkXEiryYL33c586Z3WzTtOfnt/sinp195plnZmc+8/yYzR/0Ja50Oq3r+ktIou12O5/Pv4ioVyGvI/DbjICu65lM5tfqzmQyicVii8XiRdQul8sXFxeri2o2m7VajeX/g70xDKOz5Lq9vWU5WToWi73ga2i1WhsbG6z8V/p1BF5HgFKazWYTicQPGQpd15cAQ+eff/6xVWkymciyfHV1Zft0jcLT01MOvB4V4vf7m80msn0FdrVabX9/XxAEQoggCKF/r0AgIAiCx+PRNA1rA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93uaNYaMvKaNahZR7OKwOHDh117ewmO5vnz5/j+N1TgTUA+fvyYnJz8+PFjweZfTtjV1RUbG8tz6ZhWd4WFhdhjHt3ZXlJSQmYMRdbq6upUKtXsZ+6c1rsgZUZeboDGmiwABOx2e0JCQmNj48yO9dWrV7zg8Jm178ya0Wh88uSJs9qZknd0dHh4eCyUHBuMvGbqc2d25h0CAwMDERERvLDteTfK+TSgdevWzQk1u4cBIy/3cGOtGAIMgTlGgJHXHH8ArHuGAEPAPQT+H4B3Iv8XGptiAAAAAElFTkSuQmCC"
    }
   },
   "cell_type": "markdown",
   "id": "d3a93763",
   "metadata": {},
   "source": [
    "## 朴素贝叶斯算法\n",
    "![image.png](attachment:image.png)\n",
    "数据集有时并不是很完全的，总会因为某些原因存在一些缺失和收集不全的现象，所以特征 x 越多这个问题就会越突出，统计这些特征出现的概率就越困难。为了避免这一问题，朴素贝叶斯算法做了一个假设，即特征之间相互独立，互不影响，由此以来，就可以简化为以下式子来求解某个特征的似然度：\n",
    "![image-2.png](attachment:image-2.png)\n",
    "“朴素贝叶斯算法”利用后验概率进行预测，其核心方法是通过似然度预测后验概率。在使用朴素贝叶斯算法解决分类问题，其实就是不断提高似然度的过程，你可以理解为后验概率正比于似然度，如果提高了似然度，那么也会达到提高后验概率的目的。\n",
    "![image-3.png](attachment:image-3.png)\n",
    "上述式子中∝表示正比于，而∏则是连乘符号（即概率相乘）表示了不同特征同时发生的概率。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0ba536e7",
   "metadata": {},
   "source": [
    "## 朴素贝叶斯优化方法"
   ]
  },
  {
   "attachments": {
    "image.png": {
     "image/png": "iVBORw0KGgoAAAANSUhEUgAAAMAAAAA7CAIAAACi6xKKAAANV0lEQVR4Ae1c8Wcryxe//9NhxYqKilURV1xRFbUqP+SHiCeqoSJKREXEc1Xkh/0h3LqqqiKua1XUVfVEhBD1xBMVFRVXVDxRq1Z/mK/bU8eY3bbbfpv70nT3hzozc2bmzMxnzpxzZtIPz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PmCP5O1/fni41PhaqDH5+ddlFar1Vgspmka/cLXybBPT0/L5bKiKAsLC6VSyfpjPCeNvDke9wizX7Kzs7NnvfXEl6aDwcC4+waDwez/ssV+5M/M/R8gB/R+VhDlOQAAAABJRU5ErkJggg=="
    }
   },
   "cell_type": "markdown",
   "id": "6de3be40",
   "metadata": {},
   "source": [
    "你也许会发现，在学习过朴素贝叶斯的过程中，我们并内提到“假设函数”和“损失函数”，其实这并不难理解。朴素贝叶斯算法更像是一种统计方法，通过比较不同特征与类之间的似然度关系，最后把似然度最大的类作为预测结果。\n",
    "\n",
    "每个类与特征的似然度是不同的，也就是 P(xi|y) 不同，因此某一类别中某个特征的概率越大，我们就更容易对该类别进行分类。根据求解后验概率的公式，可以得出以下优化方法：\n",
    "![image.png](attachment:image.png)\n",
    "此时将后验概率记做类别 y，我们知道 P(y) 是一个固定的概率值，因此要想让 y 取得最大值，只能通过 P(xi|y)  实现，不妨把被统计的数据看成是一张大表格，朴素贝叶斯算法就是从中找到 P(xi|y) 值最大的那一项，该项对应的 y 是什么，则最终输出的预测结果就是什么。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0b6ec3b1",
   "metadata": {},
   "source": [
    "## 简单应用案例\n",
    "假设一个学校有 45% 的男生和 55% 的女生，学校规定不能穿奇装异服，男生的裤子只能穿长筒裤，而女生可以穿裙子或者长筒裤，已知该学校穿长筒裤的女生和穿裙子的女生数量相等，所有男生都必须穿长筒裤，请问如果你从远处看到一个穿裤子的学生，那么这个学生是女生的概率是多少？\n",
    "\n",
    "学校女生的概率：P(女生)= 0.55\n",
    "女生中穿裤子的概率：P(裤子|女)= 0.5\n",
    "学校中穿裤子的概率：P(裤子)= 0.45 + 0.275= 0.725\n",
    "\n",
    "```shell\n",
    "P(女|裤子) = P(裤子|女生) * P(女生) / P(裤子) = 0.5 * 0.55 / 0.725 = 0.379\n",
    "```\n",
    "P(裤子|女生) 就是我们经常提起的条件概率“似然度”。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "79e95ffe",
   "metadata": {},
   "source": [
    "## sklearn实现朴素贝叶斯\n",
    "\n",
    "- （1）统计样本数，即统计先验概率 P(y) 和 似然度 P(x|y)。\n",
    "- （2）根据待测样本所包含的特征，对不同类分别进行后验概率计算。\n",
    "- （3）比较 y1，y2，...yn 的后验概率，哪个的概率值最大就将其作为预测输出。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "3c56ae50",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[5.1 3.5 1.4 0.2]\n",
      " [4.9 3.  1.4 0.2]\n",
      " [4.7 3.2 1.3 0.2]\n",
      " [4.6 3.1 1.5 0.2]\n",
      " [5.  3.6 1.4 0.2]\n",
      " [5.4 3.9 1.7 0.4]\n",
      " [4.6 3.4 1.4 0.3]\n",
      " [5.  3.4 1.5 0.2]\n",
      " [4.4 2.9 1.4 0.2]\n",
      " [4.9 3.1 1.5 0.1]\n",
      " [5.4 3.7 1.5 0.2]\n",
      " [4.8 3.4 1.6 0.2]\n",
      " [4.8 3.  1.4 0.1]\n",
      " [4.3 3.  1.1 0.1]\n",
      " [5.8 4.  1.2 0.2]\n",
      " [5.7 4.4 1.5 0.4]\n",
      " [5.4 3.9 1.3 0.4]\n",
      " [5.1 3.5 1.4 0.3]\n",
      " [5.7 3.8 1.7 0.3]\n",
      " [5.1 3.8 1.5 0.3]\n",
      " [5.4 3.4 1.7 0.2]\n",
      " [5.1 3.7 1.5 0.4]\n",
      " [4.6 3.6 1.  0.2]\n",
      " [5.1 3.3 1.7 0.5]\n",
      " [4.8 3.4 1.9 0.2]\n",
      " [5.  3.  1.6 0.2]\n",
      " [5.  3.4 1.6 0.4]\n",
      " [5.2 3.5 1.5 0.2]\n",
      " [5.2 3.4 1.4 0.2]\n",
      " [4.7 3.2 1.6 0.2]\n",
      " [4.8 3.1 1.6 0.2]\n",
      " [5.4 3.4 1.5 0.4]\n",
      " [5.2 4.1 1.5 0.1]\n",
      " [5.5 4.2 1.4 0.2]\n",
      " [4.9 3.1 1.5 0.2]\n",
      " [5.  3.2 1.2 0.2]\n",
      " [5.5 3.5 1.3 0.2]\n",
      " [4.9 3.6 1.4 0.1]\n",
      " [4.4 3.  1.3 0.2]\n",
      " [5.1 3.4 1.5 0.2]\n",
      " [5.  3.5 1.3 0.3]\n",
      " [4.5 2.3 1.3 0.3]\n",
      " [4.4 3.2 1.3 0.2]\n",
      " [5.  3.5 1.6 0.6]\n",
      " [5.1 3.8 1.9 0.4]\n",
      " [4.8 3.  1.4 0.3]\n",
      " [5.1 3.8 1.6 0.2]\n",
      " [4.6 3.2 1.4 0.2]\n",
      " [5.3 3.7 1.5 0.2]\n",
      " [5.  3.3 1.4 0.2]\n",
      " [7.  3.2 4.7 1.4]\n",
      " [6.4 3.2 4.5 1.5]\n",
      " [6.9 3.1 4.9 1.5]\n",
      " [5.5 2.3 4.  1.3]\n",
      " [6.5 2.8 4.6 1.5]\n",
      " [5.7 2.8 4.5 1.3]\n",
      " [6.3 3.3 4.7 1.6]\n",
      " [4.9 2.4 3.3 1. ]\n",
      " [6.6 2.9 4.6 1.3]\n",
      " [5.2 2.7 3.9 1.4]\n",
      " [5.  2.  3.5 1. ]\n",
      " [5.9 3.  4.2 1.5]\n",
      " [6.  2.2 4.  1. ]\n",
      " [6.1 2.9 4.7 1.4]\n",
      " [5.6 2.9 3.6 1.3]\n",
      " [6.7 3.1 4.4 1.4]\n",
      " [5.6 3.  4.5 1.5]\n",
      " [5.8 2.7 4.1 1. ]\n",
      " [6.2 2.2 4.5 1.5]\n",
      " [5.6 2.5 3.9 1.1]\n",
      " [5.9 3.2 4.8 1.8]\n",
      " [6.1 2.8 4.  1.3]\n",
      " [6.3 2.5 4.9 1.5]\n",
      " [6.1 2.8 4.7 1.2]\n",
      " [6.4 2.9 4.3 1.3]\n",
      " [6.6 3.  4.4 1.4]\n",
      " [6.8 2.8 4.8 1.4]\n",
      " [6.7 3.  5.  1.7]\n",
      " [6.  2.9 4.5 1.5]\n",
      " [5.7 2.6 3.5 1. ]\n",
      " [5.5 2.4 3.8 1.1]\n",
      " [5.5 2.4 3.7 1. ]\n",
      " [5.8 2.7 3.9 1.2]\n",
      " [6.  2.7 5.1 1.6]\n",
      " [5.4 3.  4.5 1.5]\n",
      " [6.  3.4 4.5 1.6]\n",
      " [6.7 3.1 4.7 1.5]\n",
      " [6.3 2.3 4.4 1.3]\n",
      " [5.6 3.  4.1 1.3]\n",
      " [5.5 2.5 4.  1.3]\n",
      " [5.5 2.6 4.4 1.2]\n",
      " [6.1 3.  4.6 1.4]\n",
      " [5.8 2.6 4.  1.2]\n",
      " [5.  2.3 3.3 1. ]\n",
      " [5.6 2.7 4.2 1.3]\n",
      " [5.7 3.  4.2 1.2]\n",
      " [5.7 2.9 4.2 1.3]\n",
      " [6.2 2.9 4.3 1.3]\n",
      " [5.1 2.5 3.  1.1]\n",
      " [5.7 2.8 4.1 1.3]\n",
      " [6.3 3.3 6.  2.5]\n",
      " [5.8 2.7 5.1 1.9]\n",
      " [7.1 3.  5.9 2.1]\n",
      " [6.3 2.9 5.6 1.8]\n",
      " [6.5 3.  5.8 2.2]\n",
      " [7.6 3.  6.6 2.1]\n",
      " [4.9 2.5 4.5 1.7]\n",
      " [7.3 2.9 6.3 1.8]\n",
      " [6.7 2.5 5.8 1.8]\n",
      " [7.2 3.6 6.1 2.5]\n",
      " [6.5 3.2 5.1 2. ]\n",
      " [6.4 2.7 5.3 1.9]\n",
      " [6.8 3.  5.5 2.1]\n",
      " [5.7 2.5 5.  2. ]\n",
      " [5.8 2.8 5.1 2.4]\n",
      " [6.4 3.2 5.3 2.3]\n",
      " [6.5 3.  5.5 1.8]\n",
      " [7.7 3.8 6.7 2.2]\n",
      " [7.7 2.6 6.9 2.3]\n",
      " [6.  2.2 5.  1.5]\n",
      " [6.9 3.2 5.7 2.3]\n",
      " [5.6 2.8 4.9 2. ]\n",
      " [7.7 2.8 6.7 2. ]\n",
      " [6.3 2.7 4.9 1.8]\n",
      " [6.7 3.3 5.7 2.1]\n",
      " [7.2 3.2 6.  1.8]\n",
      " [6.2 2.8 4.8 1.8]\n",
      " [6.1 3.  4.9 1.8]\n",
      " [6.4 2.8 5.6 2.1]\n",
      " [7.2 3.  5.8 1.6]\n",
      " [7.4 2.8 6.1 1.9]\n",
      " [7.9 3.8 6.4 2. ]\n",
      " [6.4 2.8 5.6 2.2]\n",
      " [6.3 2.8 5.1 1.5]\n",
      " [6.1 2.6 5.6 1.4]\n",
      " [7.7 3.  6.1 2.3]\n",
      " [6.3 3.4 5.6 2.4]\n",
      " [6.4 3.1 5.5 1.8]\n",
      " [6.  3.  4.8 1.8]\n",
      " [6.9 3.1 5.4 2.1]\n",
      " [6.7 3.1 5.6 2.4]\n",
      " [6.9 3.1 5.1 2.3]\n",
      " [5.8 2.7 5.1 1.9]\n",
      " [6.8 3.2 5.9 2.3]\n",
      " [6.7 3.3 5.7 2.5]\n",
      " [6.7 3.  5.2 2.3]\n",
      " [6.3 2.5 5.  1.9]\n",
      " [6.5 3.  5.2 2. ]\n",
      " [6.2 3.4 5.4 2.3]\n",
      " [5.9 3.  5.1 1.8]]\n",
      "[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n",
      " 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n",
      " 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2\n",
      " 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\n",
      " 2 2]\n",
      "[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n",
      " 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1\n",
      " 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 1 2 2 2 2\n",
      " 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2\n",
      " 2 2]\n",
      "0.96\n"
     ]
    }
   ],
   "source": [
    "#鸢尾花数据集\n",
    "from sklearn.datasets import load_iris\n",
    "\n",
    "#导入朴素贝叶斯模型，这里选用高斯分类器\n",
    "from sklearn.naive_bayes import GaussianNB\n",
    "\n",
    "#载入数据集\n",
    "X,y=load_iris(return_X_y=True)\n",
    "bayes_modle=GaussianNB()\n",
    "\n",
    "print(X)\n",
    "print(y)\n",
    "#训练数据\n",
    "bayes_modle.fit(X,y)\n",
    "\n",
    "#使用模型进行分类预测\n",
    "result=bayes_modle.predict(X)\n",
    "print(result)\n",
    "\n",
    "#对模型评分\n",
    "model_score=bayes_modle.score(X,y)\n",
    "print(model_score)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.16"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
